import request from "@/utils/request";
import {EquipOptions, MaterialOptions, ProductOptions} from "@/views/eam/csm/optionsTypes";
import {defineStore} from "pinia";
import {store} from "@/store";
import {useDictStore} from "@/store/modules/dictionary";

export const useCsmSelectOptionsStore =  defineStore("csmSelectOptionsStore", ()=> {
  const materialOptions = ref<Array<MaterialOptions>>([])
  const productOptions = ref<Array<ProductOptions>>([])
  const equipOptions = ref<Array<EquipOptions>>([])
  const queryMaterialList = async () => {
    const { data } = await request({
      url: "/eam/csmmaterialdata/getList",
      method: "POST",
      data: {
        enabled: 1,
      },
    });
    materialOptions.value = data;
  };
  const queryProductList= async () => {
    const { data } = await request({
      url: "/mdm/mdmproductinfo/getList",
      method: "POST",
      data: {
        enabled: 1,
      },
    });
    productOptions.value = data;
  };
  const queryEquipList= async () => {
    const { data } = await request({
      url: "/mdm/mdmprocessequip/getList",
      method: "POST",
      data: {
        enabled: 1,
      },
    });
    equipOptions.value = data;
  };
  const loadAll= async () =>{
    await queryMaterialList()
    await queryProductList()
    await queryEquipList()
  }
  return {
    materialOptions,
    productOptions,
    equipOptions,

    queryMaterialList,
    queryProductList,
    queryEquipList,

    loadAll,
  }
})
